package com.coldworks.coldjoke.util;

import android.content.Context;

import com.coldworks.base.manager.BasePrefManager;
import com.coldworks.coldjoke.manager.UserManager;

public class UrlUtil {

	public UrlUtil() {

	}

	public static String getTopicsUrl(String topicType, int pageStart, int limit) {
		return CONST.URL.GATHER + "?type=" + topicType + "&action=getGathers"
				+ "&start=" + pageStart + "&limit=" + limit;
	}

	// 用于不是自动登录的情况
	public static String getLoginUrl(String email, String password,
			String rememberMe) {
		return CONST.URL.PROFILE + "?action=login&email=" + email
				+ "&password=" + password + "&rememberme=" + rememberMe;
	}

	// 获取上次记录的登录信息，用于自动登录
	public static String getLoginUrlFromLocal() {
		String email = UserManager.getInstance().getUserEmail();
		String password = UserManager.getInstance().getUserPassword();
		String rememberMe = UserManager.getInstance().getRememberMe();
		return getLoginUrl(email, password, rememberMe);
	}

	public static String getRegisterUrl() {
		return CONST.URL.REGISTER;
	}

	public static String getPostJokeUrl() {
		return CONST.URL.JOKE;
	}

	public static String getJudgeUrl() {
		return CONST.URL.JUDGE;
	}

	public static String getCommentUrl() {
		return CONST.URL.LOG;
	}

	public static String getProfileUrl() {
		return CONST.URL.PROFILE;
	}

	public static String getJudgeJokeUrl(Context context) {
		return getJudgeUrl()
				+ "?action=getJoke&currentjokeid="
				+ BasePrefManager.getInstance().getStringFromPrefs(context,
						CONST.VALUE.JOKE_ID, "0");
	}

	public static String getShowGifHtml(String imgPath) {
		String uriPath;
		uriPath = "file://" + imgPath;
		String html = "<img src=\'" + uriPath + "\'>";
		return html;
	}

}
